﻿var ORG = (function (org) {
    var userCompany = '';
    var userDepartment = '';
    var userTeam = '';
    var userPost = '';
    
    org.init = function () {
        ORG.GetOrganize.init();
    }
    return org;
})(ORG || {});

//组织架构
ORG.GetOrganize = (function (organize) {
    var _baseAPIUrl = "TableData.aspx/GetOrganize";
    var _currentParams = [];
    var _loaded = false;
    organize.init = function () {
        ORG.GetOrganize.open();
    };
    organize.open = function () {
        if (!_loaded) {
            _load();
            _loaded = true;
        }
    };
    function _load(append) {
        _currentParams = {};
        var callback = append === true ?
        function (data) {
            _populate(data, true)
        } : _populate;
        Query.execute(_baseAPIUrl, _currentParams, callback)
    }
    function _populate(data, append) {
        if (data) {
            var person = JSON.parse(data);
            createComboBox("txtOrganize", { itemSource: person, style: "dropdown", autoComplete: "local" });
        }
    };
    return organize
})(ORG.GetOrganize || {});


//团队
ORG.GetPost = (function (getpost) {
    var _baseAPIUrl = "TableData.aspx/GetPost";
    var _currentParams = [];
    var _loaded = false;
    var _DeptID = '';
    getpost.init = function (deptID) {
        _DeptID = deptID;
        ORG.GetPost.open();
    };
    getpost.open = function () {
        if (!_loaded) {
            _load();
            _loaded = true;
        }
    };
    function _load(append) {
        _currentParams = {
            DeptID: _DeptID
        };
        var callback = append === true ?
        function (data) {
            _populate(data, true)
        } : _populate;
        Query.execute(_baseAPIUrl, _currentParams, callback)
    }
    function _populate(data, append) {
        if (data) {
            var person = JSON.parse(data);
            createComboBox("txtPost", { itemSource: person, style: "dropdown", autoComplete: "local" });
        }
    };
    return getpost
})(ORG.GetPost || {});